import 'package:check_app/model/subjectInfo.dart';
import 'package:json_annotation/json_annotation.dart';
part 'taskInfo.g.dart';

@JsonSerializable()
class TaskInfoResult {
  final bool success;
  final String message;
  final int total;
  final TaskInfo data;

  const TaskInfoResult(
    this.success,
    this.message,
    this.total,
    this.data,
  );

  factory TaskInfoResult.fromJson(Map json) => _$TaskInfoResultFromJson(json);
  Map toJson() => _$TaskInfoResultToJson(this);
}

@JsonSerializable()
class TaskInfo {
  final int id;
  final String type;
  final String status;
  final String code;
  final String contractNo;
  final int customerId;
  final String customerName;
  final int guideBookId;
  final String guideBookName;
  final int checkQuantity;
  final String provinceName;
  final String provinceCode;
  final String cityName;
  final String cityCode;
  final String countyName;
  final String countyCode;
  final List<OperatorItem> operatorList;
  final List<SubjectCollectItem> subjectCollectList;
  final List<SubjectCollectItem> subjectList;
  final List<String> proofUrlList;

  TaskInfo(
    this.id,
    this.type,
    this.status,
    this.code,
    this.contractNo,
    this.customerId,
    this.customerName,
    this.guideBookId,
    this.guideBookName,
    this.checkQuantity,
    this.provinceName,
    this.provinceCode,
    this.cityName,
    this.cityCode,
    this.countyName,
    this.countyCode,
    this.operatorList,
    this.subjectCollectList,
    this.subjectList,
    this.proofUrlList,
  );

  factory TaskInfo.fromJson(Map json) => _$TaskInfoFromJson(json);
  Map toJson() => _$TaskInfoToJson(this);
}

@JsonSerializable()
class OperatorItem {
  final String operatorAid;
  final String operatorName;
  final String operatorCode;

  OperatorItem(
    this.operatorAid,
    this.operatorName,
    this.operatorCode,
  );

  factory OperatorItem.fromJson(Map json) => _$OperatorItemFromJson(json);
  Map toJson() => _$OperatorItemToJson(this);
}

@JsonSerializable()
class SubjectCollectItem {
  final int id;
  final int taskId;
  final String code;
  final String largeName;
  final String subName;
  final int planQuantity;
  final int finishQuantity;
  final List<SubjectInfo> subjectList;

  SubjectCollectItem(
    this.id,
    this.taskId,
    this.code,
    this.largeName,
    this.subName,
    this.planQuantity,
    this.finishQuantity,
    this.subjectList,
  );

  factory SubjectCollectItem.fromJson(Map json) =>
      _$SubjectCollectItemFromJson(json);
  Map toJson() => _$SubjectCollectItemToJson(this);
}
